const CracoLessPlugin = require('craco-less');
const CracoAlias = require("craco-alias");

module.exports = {

  babel: {
    plugins: [
      [
        'import', // babel-plugin-import的简写
        {
          libraryName: 'antd', // 针对antd按需打包
          style: 'css' // 自动打包使用组件的css
        }
      ]
    ]
  },

  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            /* 
            覆盖内置的样式变量
            https://ant-design.antgroup.com/docs/react/customize-theme-cn
            */
            modifyVars: { 
              '@primary-color': '#1DA57A' // 全局主色
            },
            javascriptEnabled: true,
          },
        },
      },
    },

    /* https://github.com/risenforces/craco-alias */
    {
      plugin: CracoAlias,
      options: {
        source: "tsconfig",
        tsConfigPath: './tsconfig.extend.json'
      },
    },
  ],
};